<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>.
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.johnxu.net.
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 2019-03-16
 * | ---------------------------------------------------------------------------------------------------
 * | Desc:
 * | ---------------------------------------------------------------------------------------------------
 */

namespace app\admin\validate;

use think\Validate;

class Users extends Validate
{
    protected $rule
        = [
            'username' => 'require|unique:users,username',
            'password' => 'require',
            'group_id' => 'require',
            'status'   => 'require|in:normal,hidden'
        ];
    protected $message
        = [
            'username.require' => '账号不能为空',
            'username.unique'  => '账号已经存在',
            'password.require' => '密码不能为空',
            'group_id.require' => '分组编号不能为空',
            'status.require'   => '状态不能为空',
            'status.in'        => '状态错误'
        ];
    protected $scene
        = [
            'add'  => 'username,password,group_id,status',
            'edit' => [
                'username' => 'require',
                'group_id',
                'status'
            ]
        ];
}